<template>
	<el-dialog v-model="visible" title="物料选择" :close-on-click-modal='false' :close-on-press-escape='false'
		:fullscreen='false' width ="70%" >
		<el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
			<el-form-item>
				<el-input size="small" v-model="dataForm.sku" placeholder="物料编码" clearable></el-input>
			</el-form-item>
			<el-form-item>
				<el-input size="small" v-model="dataForm.descr" placeholder="物料名称" clearable></el-input>
			</el-form-item>
			<el-form-item>
				<el-input size="small" v-model="dataForm.factorycdoe" placeholder="计量编码/工装号" clearable></el-input>
			</el-form-item>
			<el-form-item>
				<el-input size="small" v-model="dataForm.product" placeholder="产品代号" clearable></el-input>
			</el-form-item>
			<el-form-item>
				<el-button size="small" @click="getDataList()">查询</el-button>
			</el-form-item>
		</el-form>
		<el-table v-loading="dataListLoading" :data="dataList" border @selection-change="dataListSelectionChangeHandle"
			@sort-change="dataListSortChangeHandle" style="width: 100%;">
			<el-table-column prop="sku" label="物料编码" header-align="center" align="center"></el-table-column>
			<el-table-column prop="descr" label="物料名称" header-align="center" align="center"></el-table-column>
			<el-table-column prop="categoryname" label="分类" header-align="center" align="center"></el-table-column>
			<el-table-column prop="unit" label="单位" header-align="center" align="center"></el-table-column>
			<el-table-column prop="price" label="价格" header-align="center" align="center"></el-table-column>
			<el-table-column prop="isconsumablestr" label="是否消耗品" header-align="center" align="center"></el-table-column>
			<el-table-column prop="factory" label="生产厂家" header-align="center" align="center"></el-table-column>
			<el-table-column prop="factorycdoe" label="计量编码/工装号" header-align="center" align="center"></el-table-column>
			<el-table-column prop="product" label="产品代号" header-align="center" align="center"></el-table-column>
			<el-table-column prop="isuniquecodestr" label="唯一码管理" header-align="center" align="center"></el-table-column>
			<el-table-column label='操作' fixed="right" header-align="center" align="center"  width="80" >
				<template #default="scope">
					<el-button type="text" size="small" @click="selectOrderdetailHandleFn(scope.row)">选择
					</el-button>
				</template>
			</el-table-column>
		</el-table>
		<el-pagination :current-page="page" :page-sizes="[10, 20, 50, 100]" :page-size="limit" :total="total"
			layout="total, sizes, prev, pager, next, jumper" @size-change="pageSizeChangeHandle"
			@current-change="pageCurrentChangeHandle">
		</el-pagination>
	</el-dialog>
</template>

<script>
		import DataList from "@/utils/DataList";
	import {
		ref,
		reactive,
		onMounted,
		nextTick,
		computed
	} from 'vue';

	import {
		ElMessage
	} from 'element-plus'
	import {
		getzonelist
	} from "@/network/lswms/base/Zone.js"
	import {
		getPutawaystrategyPage
	} from "@/network/lswms/base/Putawaystrategy.js"
	import {
		getAllocationstrategyPage
	} from "@/network/lswms/base/Allocationstrategy.js"
	import {
		getCodeListByCode
	} from "@/network/lswms/base/Codelist.js"
	import _ from 'lodash'


	export default {
		name: "skuAddOrUpdate",
		emits: ["fillline"],
		setup(props, {
			emit
		}) {
			const {
				mixinViewModuleOptions,
				order,
				orderField,
				dataList,
				total,
				page,
				limit,
				dataListLoading,
				dataListSelectionChangeHandle,
				dataListSortChangeHandle,
				pageSizeChangeHandle,
				pageCurrentChangeHandle,
				addOrUpdateHandle,
				deleteHandle,
				exportHandle,
				addOrUpdateVisible,
				dataListSelections,
				addOrUpdate,
				getDataList,
				dataForm
			} = DataList();
			
			onMounted(() => {
				
				mixinViewModuleOptions.value.getDataListIsPage = true;
				mixinViewModuleOptions.value.getDataListURL = '/lswms/sku/page';
				mixinViewModuleOptions.value.deleteURL = '/lswms/sku';
				mixinViewModuleOptions.value.exportURL = '/lswms/sku/export';
				mixinViewModuleOptions.value.deleteIsBatchKey = 'id';
				mixinViewModuleOptions.value.deleteIsBatch = true
				if (mixinViewModuleOptions.value.activatedIsNeed) {
					getDataList();
				}
			})
			
			const visible = ref(false)
			
			const init = ()=>{
				visible.value = true;
			}
			
			const selectOrderdetailHandleFn = (row) => {
				emit('fillline', row);
				visible.value = false;
			}
			
			return {
			
				mixinViewModuleOptions,
				order,
				orderField,
				dataList,
				total,
				page,
				limit,
				dataListLoading,
				dataListSelectionChangeHandle,
				dataListSortChangeHandle,
				pageSizeChangeHandle,
				pageCurrentChangeHandle,
				addOrUpdateHandle,
				deleteHandle,
				exportHandle,
				addOrUpdateVisible,
				dataListSelections,
				addOrUpdate,
				selectOrderdetailHandleFn,
				getDataList,
				init,
				visible,
				dataForm
			
			}
		},
		methods: {
			reString: function(val) {
				let n = Number(val)
				if (!isNaN(n)) {
					return n
				} else {
					return val
				}
			}
		}

	}
</script>

<style scoped>

</style>
